package com.作业.Day9;

import java.util.Scanner;

public class Homework4 {
    public static void main(String[] args) {
        Goods goods = new Goods();
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入用户名:");
        String username = scanner.next();
        System.out.println("请输入密码");
        String password = scanner.next();
        goods.login(username, password);
        goods.show();
        System.out.println("请输入您批发的商品编号");
        int i = scanner.nextInt();
        System.out.println("请输入批发数量");
        int i1 = scanner.nextInt();
        double select = goods.select(i, i1);
        StringBuffer change = goods.change(select);
        System.out.println("您需要付款" + change);

    }


}

class Goods {
    boolean login(String username, String password) {
        if (username.equals("admin") && password == "123456") {
            System.out.println("登录成功");
            return true;
        } else {
            System.out.println("登陆失败");
            return false;
        }
    }

    void show() {
        System.out.println("***********欢迎进入商品批发城************");
        System.out.println("  编号        商品     价格");
        System.out.println("   2         洗衣机    190000.23   ");
        System.out.println("   2         洗衣机    190000   ");
        System.out.println("   2         洗衣机    190000   ");
        System.out.println("   2         洗衣机    190000   ");
        System.out.println("   2         洗衣机    190000   ");
        System.out.println("   2         洗衣机    190000   ");
        System.out.println("   2         洗衣机    190000   ");
        System.out.println("   2         洗衣机    190000   ");
        System.out.println("   2         洗衣机    190000   ");

    }

    double select(int a, int nums) {
        double b = 0;
        switch (a) {
            case 1:
                b = 1234.334 * nums;
                break;
            case 2:
                b = 1234.34 * nums;
                break;
            case 3:
                b = 12314.334 * nums;
                break;
            case 4:
                b = 123421.334 * nums;
                break;
            case 5:
                b = 1234.3334 * nums;
                break;
            case 6:
                b = 1234.33444 * nums;
                break;

        }
        return b;
    }

    /**
     * 付款
     */
    public StringBuffer change(double d) {
        StringBuffer str = new StringBuffer(String.valueOf(d));
        for (int i = str.indexOf(".") - 3; i > 0; i = i - 3) {
            str.insert(i, ",");

        }
        return str;
    }
}
